package cn.skyquant.quant4j.sdk.enums;

public enum TradeDirection {
    LONG("多"),
    SHORT("空"),
    BOTH("双向");
    public String desc;
    public String shortstr;

    TradeDirection(String desc){
        this.desc = desc;
        this.shortstr = name().substring(0,1);
    }

    public static TradeDirection parse(String orderType) {
        if("b".equalsIgnoreCase(orderType) || "buy".equalsIgnoreCase(orderType) || "l".equalsIgnoreCase(orderType)|| "long".equalsIgnoreCase(orderType)){
            return LONG;
        }
        if("s".equalsIgnoreCase(orderType) || "sell".equalsIgnoreCase(orderType) || "s".equalsIgnoreCase(orderType)|| "short".equalsIgnoreCase(orderType)){
            return SHORT;
        }
        return BOTH;
    }

    @Override
    public String toString() {
        return desc;
    }

    public boolean isLong(){
        return this == LONG;
    }

    public boolean isShort() {
        return this == SHORT;
    }
}
